package com.biz.primus.ms.price.api;


import com.biz.primus.base.vo.price.PriceItemVo;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.model.price.vo.*;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.price.service.PriceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yanweijin
 * @date 2017/9/12
 */
@RestController
@RequestMapping("soa/priceService")
public class PriceApiController extends BaseApiController {

    private final PriceService priceService;

    public PriceApiController(PriceService priceService) {
        this.priceService = priceService;
    }


    @ApiOperation("批量价格获取" +
            "1:返回结果强制有序,对于没有价格的商品数据,用null填充list" +
            "2:todo 组合商品全国定价取价逻辑,待补充")
    @PostMapping("prices")
    BatchPriceVo prices(@RequestBody PriceReqVo priceReqVo){
        return this.priceService.prices(priceReqVo);
    }

    @PostMapping("findAllPrice")
    SpringPageVO<PriceItemVo> findAllPrice(@RequestBody PriceQueryVo reqVo){
        return priceService.findAllPrice(reqVo);
    }

    @ApiOperation("erp同步价格")
    @PostMapping("syncPrices")
    void syncPrices(@RequestBody List<SyncPriceVo> reqVos){
        priceService.syncPrices(reqVos);
    }

    @ApiOperation("erp同步规格价格")
    @PostMapping("syncSpecPrices")
    void syncSpecPrices(@RequestBody List<SyncSpecPriceVo> reqVos){
        priceService.syncSpecPrices(reqVos);
    }

}
